using System;
using System.Collections.Generic;
using System.Text;

namespace SWAS.Web.UI.Controls
{
    [Serializable]
    public class SelectedValueCollection
    {
        private List<SelectedValue> values;

        public SelectedValueCollection()
        {
            values = new List<SelectedValue>();
        }

        public void Add(SelectedValue value)
        {
            if (!this.Contains(value))
            {
                values.Add(value);
            }
        }

        public void AddRange(SelectedValue[] value)
        {
            foreach (SelectedValue v in value)
            {
                this.Add(v);
            }
        }

        public SelectedValue[] ToArray()
        {
            return values.ToArray();
        }

        public void Remove(SelectedValue value)
        {
            int index = this.IndexOf(value);
            if (index > -1)
            {
                values.RemoveAt(index);
            }
        }

        public SelectedValue this[int index]
        {
            get { return values[index]; }
        }

        public bool Contains(SelectedValue value)
        {
            foreach (SelectedValue v in values)
            {
                if (v.Equals(value))
                {
                    return true;
                }
            }
            return false;
        }

        public int IndexOf(SelectedValue value)
        {
            foreach (SelectedValue v in values)
            {
                if (v.Equals(value))
                {
                    return values.IndexOf(v);
                }
            }
            return -1;
        }

    }
}
